home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include <sys/types.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
-
- #include <X11/Intrinsic.h>
- #include <X11/StringDefs.h>
- #include <Xm/Frame.h>
- #include <Xm/PushB.h>
-
- #include "main.h"
- #include "interfere.h"
-
- /*
- * For naming the widgets' resources.
- */
- #define APP_NAME "interfere"
- #define APP_CLASS "Interfere"
-
- /*
- * In case there's no app-defaults file.
- */
- static String fallbacks[] =
- {
- "*canvasFrame.width: 500",
- "*canvasFrame.height: 400",
- "*canvasFrame.leftOffset: 20",
- "*canvasFrame.topOffset: 40",
- "*canvasFrame.rightOffset: 120",
- "*canvasFrame.bottomOffset: 40",
- "*Quit.rightOffset: 10",
- "*Quit.bottomOffset: 10",
- "*Animate.rightOffset: 10",
- "*Animate.bottomOffset: 50",
- NULL,
- };
-
- /*
- * Called from main() when the toplevel widget is created.
- */
- char *
- getAppName (void)
- {
- return APP_NAME;
- }
-
- /*
- * Called from main() when the toplevel widget is created.
- */
- char *
- getAppClass (void)
- {
- return APP_CLASS;
- }
-
- /*
- * So that the XtOpenDisplay can set them in main().
- */
- void
- setFallbackResources(XtAppContext app_context)
- {
- XtAppSetFallbackResources(app_context, fallbacks);
- }
-
- /*
- * This is called until we press the 'Stop' button.
- */
- static Boolean
- animateWorkProc (XtPointer client_data)
- {
- drawScene ();
- return False;
- }
-
- /*
- * If there are any application-specific resources, specify them here.
- */
- XrmOptionDescRec *
- getResourceDescriptions (int * num_desc)
- {
- *num_desc = 0;
- return NULL;
- }
-
- /*
- * Using the framing widget's dimensions, request a gl drawing area.
- */
- Widget
- setupGLWidget (Widget parent)
- {
- Arg args[2];
- unsigned int n = 0;
- unsigned int width = 0, height = 0;
- Widget canvas = NULL;
-
- XtVaGetValues(parent,
- XmNwidth, &width,
- XmNheight, &height,
- NULL);
- canvas = initGLWidget(parent, width, height);
- return canvas;
- }
-
- /*
- * Used when the Animate/Stop button is pressed.
- */
- static void
- animateCallback (Widget w, XtPointer client, XtPointer callback)
- {
- static Boolean toggle = False;
- static work_proc_id = 0;
- XmString string;
- XtAppContext app_context = (XtAppContext)client;
-
- if (!toggle) {
- Boolean animateWorkProc(XtPointer);
- work_proc_id = XtAppAddWorkProc(app_context, animateWorkProc, NULL);
- string = XmStringCreateSimple("Stop");
- toggle = True;
- }
- else {
- XtRemoveWorkProc(work_proc_id);
- string = XmStringCreateSimple("Animate");
- toggle = False;
- }
-
- XtVaSetValues(w, XmNlabelString, string, NULL);
- XmStringFree(string);
- }
-
- /*
- *
- */
- static void
- quitCallback (Widget w, XtPointer client, XtPointer callback)
- {
- exit(0);
- }
-
- /*
- * Set up the application's desktop.
- */
- Widget
- setupDesktop (Widget parent, XtAppContext app_context)
- {
- Widget quit_button = XtVaCreateManagedWidget
- ("Quit", xmPushButtonWidgetClass, parent,
- XmNrightAttachment, XmATTACH_FORM,
- XmNbottomAttachment, XmATTACH_FORM,
- XmNtraversalOn, False,
- NULL);
- Widget animate_button = XtVaCreateManagedWidget
- ("Animate", xmPushButtonWidgetClass, parent,
- XmNrightAttachment, XmATTACH_FORM,
- XmNbottomAttachment, XmATTACH_FORM,
- XmNtraversalOn, False,
- NULL);
-
- Widget frame = XtVaCreateWidget("canvasFrame", xmFrameWidgetClass,
- parent,
- XmNbottomAttachment, XmATTACH_FORM,
- XmNtopAttachment, XmATTACH_FORM,
- XmNleftAttachment, XmATTACH_FORM,
- XmNrightAttachment, XmATTACH_FORM,
- NULL);
-
-
- XtAddCallback(animate_button, XmNactivateCallback, animateCallback,
- app_context);
- XtAddCallback(quit_button, XmNactivateCallback, quitCallback, NULL);
- return frame;
- }
-
- /*
- * Manage the framing widget. Creating and managing became a two
- * step process to decouple the GL drawing area creation from an
- * Open GL or GL specific widget. The glXgetConfig didn't like
- * some of the parameters I'd specified for the GL implementation.
- */
- void
- showGLWidget (Widget parent)
- {
- XtManageChild(parent);
- }
-
-